<template>
    <el-popconfirm title="确信要永久性删除不可恢复?"  @confirm="onClick" v-if="popConfirm">
      <template #reference>
        <el-button :type="type" :size="size">{{fvData.fdLayout.label}}</el-button>
      </template>
    </el-popconfirm>
  <el-button :type="type" :size="size" @click="onClick" v-else>{{fvData.fdLayout.label}}</el-button>
</template>

<script>
import { computed } from 'vue'
import ConstDef from '../../js/ConstDef'
export default {
  name: 'NvButton',
  props: {
    fvData: {
      default: null,
      type: Object
    },
    type: {
      type: String,
      default: 'primary'
    },
    size: {
      type: String,
      default: 'small'
    }
  },
  setup(props) {
    const nv = computed(() => {
      return props.fvData.getNv();
    });
    const popConfirm = computed(() => {
      return props.fvData && props.fvData.fdLayout.functionCode === ConstDef.FUNCTION_CODE_DELETE;
    })
    return {
      nv,
      popConfirm
    }
  },
  methods: {
    onClick() {
      this.$emit("define-event", { fvData: this.fvData })
    }
  }
}
</script>

<style scoped>

</style>
